[!if FPCPRT != ""]
	Copyright (c) 2011-2012 by MicroStrategy, Inc.  This copyrighted material
	is the confidential, unpublished property of MicroStrategy.  This
	copyright notice and any other copyright notices included in machine
	readable copies must be reproduced on all authorized copies.
[!endif]
//=======================================================================
[!output COPYRIGHT_MSG]
//
//		File:	FPClasses.h
//
//		Date:	[!output FPDATE]
//
//		Desc:	Declaration of function plug-in classes.
//=======================================================================

#ifndef __FPCLASSES_H_
#define __FPCLASSES_H_

#include "resource.h"       // main symbols
#include "[!output safe_root].h"
[!if RFUNCS_DEFINED != ""]#include "RSupport.h"[!endif]

const Int_32 ERRMSG_BUFSIZE = 256;

//=======================================================================
// [!output FUNCPACKAGE_CLASSNAME]
//=======================================================================
class ATL_NO_VTABLE [!output FUNCPACKAGE_CLASSNAME] : 
	public CComObjectRootEx<CComMultiThreadModel>,
	public CComCoClass<[!output FUNCPACKAGE_CLASSNAME], &[!output FUNCPACKAGE_CLSIDNAME]>,
	public IDispatchImpl<[!output FUNCPACKAGE_INTERFACE], &[!output FUNCPACKAGE_DEFIIDNAME], &LIBID_[!output safe_root]Lib>,
	public ICDSSFunctionPackage2
{
public:
	[!output FUNCPACKAGE_CLASSNAME]()
	{
[!if RFUNCS_DEFINED != ""]
		m_pRSupp = NULL;
[!endif]
	}
	~[!output FUNCPACKAGE_CLASSNAME]()
	{
[!if RFUNCS_DEFINED != ""]
		delete m_pRSupp;
[!endif]
	}

DECLARE_REGISTRY_RESOURCEID(IDR_[!output SAFE_ROOT])

DECLARE_PROTECT_FINAL_CONSTRUCT()

BEGIN_COM_MAP([!output FUNCPACKAGE_CLASSNAME])
	COM_INTERFACE_ENTRY([!output FUNCPACKAGE_INTERFACE])
	COM_INTERFACE_ENTRY(IDispatch)
	COM_INTERFACE_ENTRY(ICDSSFunctionPackage)
	COM_INTERFACE_ENTRY(ICDSSFunctionPackage2)
END_COM_MAP()

// [!output FUNCPACKAGE_INTERFACE]
[!if RFUNCS_DEFINED != ""]
private:
	CRSupport *m_pRSupp;
[!endif]
public:
// ICDSSFunctionPackage2
	STDMETHOD(Count)(Int_32 *pCount);
	STDMETHOD(Item)(Int_32 Index, ICDSSFunctionObject **ppFunctionObject);
	STDMETHOD(get_Name)(BSTR *pName);
	STDMETHOD(get_Version)(BSTR *pVersion);
	STDMETHOD(get_Description)(BSTR *pDescription);
	STDMETHOD(get_CLSID)(GUID *pCLSID);
	STDMETHOD(get_CLSIDString)(BSTR *pCLSIDString);
	STDMETHOD(get_FunctionName)(Int_32 Index, BSTR *pName);
[!if RFUNCS_DEFINED != ""]

	CRSupport *AllocRSupp();
[!endif]
};
[!if FUNCSIM_COUNT]

//=======================================================================
// [!output FUNCSIM_CLASSNAME]
//=======================================================================
class ATL_NO_VTABLE [!output FUNCSIM_CLASSNAME] : 
	public CComObjectRootEx<CComMultiThreadModel>,
	public CComCoClass<[!output FUNCSIM_CLASSNAME], &[!output FUNCSIM_CLSIDNAME]>,
	public IDispatchImpl<[!output FUNCSIM_INTERFACE], &[!output FUNCSIM_DEFIIDNAME], &LIBID_[!output safe_root]Lib>,
	public IErrorInfo,
	public ICDSSFunctionObject2,
	public ICDSSSimpleFunction
{
public:
	[!output FUNCSIM_CLASSNAME]();
	~[!output FUNCSIM_CLASSNAME]();

DECLARE_REGISTRY_RESOURCEID(IDR_[!output SAFE_ROOT])

DECLARE_PROTECT_FINAL_CONSTRUCT()

BEGIN_COM_MAP([!output FUNCSIM_CLASSNAME])
	COM_INTERFACE_ENTRY([!output FUNCSIM_INTERFACE])
	COM_INTERFACE_ENTRY(IDispatch)
	COM_INTERFACE_ENTRY(IErrorInfo)
	COM_INTERFACE_ENTRY(ICDSSFunctionObject)
	COM_INTERFACE_ENTRY(ICDSSFunctionObject2)
	COM_INTERFACE_ENTRY(ICDSSSimpleFunction)
END_COM_MAP()

// [!output FUNCSIM_INTERFACE]
public:
// IErrorInfo
	STDMETHOD(GetDescription)(BSTR *pDesc);
	STDMETHOD(GetGUID)(struct _GUID *);
	STDMETHOD(GetSource)(BSTR *);
	STDMETHOD(GetHelpFile)(BSTR *);
	STDMETHOD(GetHelpContext)(unsigned long *);
// ICDSSFunctionObject2
	STDMETHOD(get_FunctionType)(EnumDSSFunctionType *pType);
	STDMETHOD(SetProperty)(Int_32 Index, VARIANT *pValue);
	STDMETHOD(get_Description)(BSTR *pDescription);
	STDMETHOD(get_ParamCount)(Int_32 *pInCount, Int_32 *pOutCount, Int_32 *pRepeatCount);
	STDMETHOD(get_ParamInfo)(Int_32 ParamIndex, Int_32 InParameter, BSTR *pName, enum EnumDSSParameterType *pType);
	STDMETHOD(get_SqlType)(enum EnumDSSFunctionSQLType *pSqlType);
	STDMETHOD(get_PropertyCount)(Int_32 *pCount);
	STDMETHOD(get_PropertyInfo)(Int_32 PropertyIndex, BSTR *pName, BSTR *pDescription, VARIANT *pValue);
// ICDSSSimpleFuntion
	STDMETHOD(Calculate)(Int_32 nParam, double *pParam, double *pResult, DSSData_Flags *pFlag);
	STDMETHOD(CalculateRepeat)(Int_32 nParam, Int_32 nRepeat, double **pParam, double *pResult, DSSData_Flags *pFlag);
[!if RFUNCS_DEFINED != ""]
	STDMETHOD(Init)(Int_32 lFunctionIndex, [!output FUNCPACKAGE_CLASSNAME] *pPKG, bool bRFunc);
[!else]
	STDMETHOD(Init)(Int_32 lFunctionIndex);
[!endif]
private:
	Int_32 m_lFunctionIndex;				// current function index
	wchar_t m_sErrMsg[ERRMSG_BUFSIZE];		// function plug-in error message buffer
[!if RFUNCS_DEFINED != ""]
	bool m_bRFunc;							// indicates R function
	[!output FUNCPACKAGE_CLASSNAME] *m_pPKG;		// pointer to FP package object
	CRSupport *m_pRSupp;					// pointer to package RSupport object
[!endif]
[!loop = FUNCSIM_COUNT]
[!output IF_DIRECTIVE] FUNCSIM_PROPVARS_[!output LOOP_COUNTER] != ""]
[!output OUTPUT_DIRECTIVE] FUNCSIM_PROPVARS_[!output LOOP_COUNTER]]
[!output ENDIF_DIRECTIVE][!endloop]
	// TODO: add any member variables required by your function plug-in(s)

[!loop = FUNCSIM_COUNT]	STDMETHOD([!output OUTPUT_DIRECTIVE] FUNCSIM_FUNCNAME_[!output LOOP_COUNTER]])(Int_32 nParam, double *pParam, double *pResult, DSSData_Flags *pFlag);
[!endloop]};
[!endif]
[!if FUNCNNSIM_COUNT]

//=======================================================================
// [!output FUNCNNSIM_CLASSNAME]
//=======================================================================
class ATL_NO_VTABLE [!output FUNCNNSIM_CLASSNAME] : 
	public CComObjectRootEx<CComMultiThreadModel>,
	public CComCoClass<[!output FUNCNNSIM_CLASSNAME], &[!output FUNCNNSIM_CLSIDNAME]>,
	public IDispatchImpl<[!output FUNCNNSIM_INTERFACE], &[!output FUNCNNSIM_DEFIIDNAME], &LIBID_[!output safe_root]Lib>,
	public IErrorInfo,
	public ICDSSFunctionObject2,
	public ICDSSNNSimpleFunction
{
public:
	[!output FUNCNNSIM_CLASSNAME]();
	~[!output FUNCNNSIM_CLASSNAME]();

DECLARE_REGISTRY_RESOURCEID(IDR_[!output SAFE_ROOT])

DECLARE_PROTECT_FINAL_CONSTRUCT()

BEGIN_COM_MAP([!output FUNCNNSIM_CLASSNAME])
	COM_INTERFACE_ENTRY([!output FUNCNNSIM_INTERFACE])
	COM_INTERFACE_ENTRY(IDispatch)
	COM_INTERFACE_ENTRY(IErrorInfo)
	COM_INTERFACE_ENTRY(ICDSSFunctionObject)
	COM_INTERFACE_ENTRY(ICDSSFunctionObject2)
	COM_INTERFACE_ENTRY(ICDSSNNSimpleFunction)
END_COM_MAP()

// [!output FUNCNNSIM_INTERFACE]
public:
// IErrorInfo
	STDMETHOD(GetDescription)(BSTR *pDesc);
	STDMETHOD(GetGUID)(struct _GUID *);
	STDMETHOD(GetSource)(BSTR *);
	STDMETHOD(GetHelpFile)(BSTR *);
	STDMETHOD(GetHelpContext)(unsigned long *);
// ICDSSFunctionObject2
	STDMETHOD(get_FunctionType)(EnumDSSFunctionType *pType);
	STDMETHOD(SetProperty)(Int_32 Index, VARIANT *pValue);
	STDMETHOD(get_Description)(BSTR *pDescription);
	STDMETHOD(get_ParamCount)(Int_32 *pInCount, Int_32 *pOutCount, Int_32 *pRepeatCount);
	STDMETHOD(get_ParamInfo)(Int_32 ParamIndex, Int_32 InParameter, BSTR *pName, enum EnumDSSParameterType *pType);
	STDMETHOD(get_SqlType)(enum EnumDSSFunctionSQLType *pSqlType);
	STDMETHOD(get_PropertyCount)(Int_32 *pCount);
	STDMETHOD(get_PropertyInfo)(Int_32 PropertyIndex, BSTR *pName, BSTR *pDescription, VARIANT *pValue);
// ICDSSNNSimpleFuntion
	STDMETHOD(Calculate)(Int_32 nParam, VARIANT *pParam, VARIANT *pResult, DSSData_Flags *pFlag);
	STDMETHOD(CalculateRepeat)(Int_32 nParam, Int_32 nRepeat, VARIANT *pParam, VARIANT *pResult, DSSData_Flags *pFlag);
	STDMETHOD(GetOutputType)(Int_32 nSize, enum EnumDSSDataType *InputType, enum EnumDSSDataType *OutputType);
[!if RFUNCS_DEFINED != ""]
	STDMETHOD(Init)(Int_32 lFunctionIndex, [!output FUNCPACKAGE_CLASSNAME] *pPKG, bool bRFunc);
[!else]
	STDMETHOD(Init)(Int_32 lFunctionIndex);
[!endif]
// support functions
	STDMETHOD(ConvertFromVariant)(VARIANT *pVar, enum EnumDSSDataType iType, BYTE *pData);
	STDMETHOD(getParamFromVariant)(VARIANT *pParam, Int_32 index, enum EnumDSSDataType type, BYTE *outResult);
private:
	Int_32 m_lFunctionIndex;				// current function index
	wchar_t m_sErrMsg[ERRMSG_BUFSIZE];		// function plug-in error message buffer
[!if RFUNCS_DEFINED != ""]
	bool m_bRFunc;							// indicates R function
	[!output FUNCPACKAGE_CLASSNAME] *m_pPKG;		// pointer to FP package object
	CRSupport *m_pRSupp;					// pointer to package RSupport object
[!endif]
[!loop = FUNCNNSIM_COUNT]
[!output IF_DIRECTIVE] FUNCNNSIM_PROPVARS_[!output LOOP_COUNTER] != ""]
[!output OUTPUT_DIRECTIVE] FUNCNNSIM_PROPVARS_[!output LOOP_COUNTER]]
[!output ENDIF_DIRECTIVE][!endloop]
	// TODO: add any member variables required by your function plug-in(s)

[!loop = FUNCNNSIM_COUNT]	STDMETHOD([!output OUTPUT_DIRECTIVE] FUNCNNSIM_FUNCNAME_[!output LOOP_COUNTER]])(Int_32 nParam, VARIANT *pParam, VARIANT *pResult, DSSData_Flags *pFlag);
[!endloop]};
[!endif]
[!if FUNCGEN_COUNT]

//=======================================================================
// [!output FUNCGEN_CLASSNAME]
//=======================================================================
class ATL_NO_VTABLE [!output FUNCGEN_CLASSNAME] : 
	public CComObjectRootEx<CComMultiThreadModel>,
	public CComCoClass<[!output FUNCGEN_CLASSNAME], &[!output FUNCGEN_CLSIDNAME]>,
	public IDispatchImpl<[!output FUNCGEN_INTERFACE], &[!output FUNCGEN_DEFIIDNAME], &LIBID_[!output safe_root]Lib>,
	public IErrorInfo,
	public ICDSSFunctionObject2,
	public ICDSSGenericFunction
{
public:
	[!output FUNCGEN_CLASSNAME]();
	~[!output FUNCGEN_CLASSNAME]();

DECLARE_REGISTRY_RESOURCEID(IDR_[!output SAFE_ROOT])

DECLARE_PROTECT_FINAL_CONSTRUCT()

BEGIN_COM_MAP([!output FUNCGEN_CLASSNAME])
	COM_INTERFACE_ENTRY([!output FUNCGEN_INTERFACE])
	COM_INTERFACE_ENTRY(IDispatch)
	COM_INTERFACE_ENTRY(IErrorInfo)
	COM_INTERFACE_ENTRY(ICDSSFunctionObject)
	COM_INTERFACE_ENTRY(ICDSSFunctionObject2)
	COM_INTERFACE_ENTRY(ICDSSGenericFunction)
END_COM_MAP()

// [!output FUNCGEN_INTERFACE]
public:
// IErrorInfo
	STDMETHOD(GetDescription)(BSTR *pDesc);
	STDMETHOD(GetGUID)(struct _GUID *);
	STDMETHOD(GetSource)(BSTR *);
	STDMETHOD(GetHelpFile)(BSTR *);
	STDMETHOD(GetHelpContext)(unsigned long *);
// ICDSSFunctionObject2
	STDMETHOD(get_FunctionType)(EnumDSSFunctionType *pType);
	STDMETHOD(SetProperty)(Int_32 Index, VARIANT *pValue);
	STDMETHOD(get_Description)(BSTR *pDescription);
	STDMETHOD(get_ParamCount)(Int_32 *pInCount, Int_32 *pOutCount, Int_32 *pRepeatCount);
	STDMETHOD(get_ParamInfo)(Int_32 ParamIndex, Int_32 InParameter, BSTR *pName, enum EnumDSSParameterType *pType);
	STDMETHOD(get_SqlType)(enum EnumDSSFunctionSQLType *pSqlType);
	STDMETHOD(get_PropertyCount)(Int_32 *pCount);
	STDMETHOD(get_PropertyInfo)(Int_32 PropertyIndex, BSTR *pName, BSTR *pDescription, VARIANT *pValue);
// ICDSSGenericFunction
	STDMETHOD(Calculate)();
	STDMETHOD(GetOutput)(Int_32 nSize, Int_32 *nDataSize, double *pData, DSSData_Flags *pFlag);
	STDMETHOD(GetOutputType)(EnumDSSParameterType * pType);
	STDMETHOD(SetInputParam)(Int_32 nParamIndex, Int_32 nSize, double *pData, DSSData_Flags *pFlag);
	STDMETHOD(GetInputParamType)(Int_32 nParamIndex, EnumDSSParameterType *pType);
	STDMETHOD(Clear)();
	STDMETHOD(IsNullProcessable)(VARIANT_BOOL *pCanProcessNULL)
	{
		if (pCanProcessNULL == NULL)
			return E_POINTER;
			
		*pCanProcessNULL = VARIANT_TRUE;

		return S_OK;
	}
[!if RFUNCS_DEFINED != ""]
	STDMETHOD(Init)(Int_32 lFunctionIndex, [!output FUNCPACKAGE_CLASSNAME] *pPKG, bool bRFunc);
[!else]
	STDMETHOD(Init)(Int_32 lFunctionIndex);
[!endif]
private:
	Int_32 m_lFunctionIndex;				// current function index
	wchar_t m_sErrMsg[ERRMSG_BUFSIZE];		// function plug-in error message buffer
[!if RFUNCS_DEFINED != ""]
	bool m_bRFunc;							// indicates R function
	[!output FUNCPACKAGE_CLASSNAME] *m_pPKG;		// pointer to FP package object
	CRSupport *m_pRSupp;					// pointer to package RSupport object
[!endif]
[!if FUNCGEN_VECTOR_INPUT != ""]
	Int_32 m_lInputSize;					// number of input rows
[!endif]
	Int_32 m_lRepeatCnt;					// number of input columns for last repeated input
[!loop = FUNCGEN_COUNT]
	// [!output OUTPUT_DIRECTIVE] FUNCGEN_FUNCNAME_[!output LOOP_COUNTER]] parameters
[!output OUTPUT_DIRECTIVE] FUNCGEN_INPARAMDECLS_[!output LOOP_COUNTER]]
[!output IF_DIRECTIVE] FUNCGEN_PROPVARS_[!output LOOP_COUNTER] != ""]
[!output OUTPUT_DIRECTIVE] FUNCGEN_PROPVARS_[!output LOOP_COUNTER]]
[!output ENDIF_DIRECTIVE][!endloop]
	// TODO: add any member variables required by your function plug-in(s)

[!loop = FUNCGEN_COUNT]	STDMETHOD([!output OUTPUT_DIRECTIVE] FUNCGEN_FUNCNAME_[!output LOOP_COUNTER]])(Int_32 nSize, Int_32 *nDataSize, double *pData, DSSData_Flags *pFlag);
[!endloop]};
[!endif]
[!if FUNCNNGEN_COUNT]

//=======================================================================
// [!output FUNCNNGEN_CLASSNAME]
//=======================================================================
class ATL_NO_VTABLE [!output FUNCNNGEN_CLASSNAME] : 
	public CComObjectRootEx<CComMultiThreadModel>,
	public CComCoClass<[!output FUNCNNGEN_CLASSNAME], &[!output FUNCNNGEN_CLSIDNAME]>,
	public IDispatchImpl<[!output FUNCNNGEN_INTERFACE], &[!output FUNCNNGEN_DEFIIDNAME], &LIBID_[!output safe_root]Lib>,
	public IErrorInfo,
	public ICDSSFunctionObject2,
	public ICDSSNNGenericFunction
{
public:
	[!output FUNCNNGEN_CLASSNAME]();
	~[!output FUNCNNGEN_CLASSNAME]();

DECLARE_REGISTRY_RESOURCEID(IDR_[!output SAFE_ROOT])

DECLARE_PROTECT_FINAL_CONSTRUCT()

BEGIN_COM_MAP([!output FUNCNNGEN_CLASSNAME])
	COM_INTERFACE_ENTRY([!output FUNCNNGEN_INTERFACE])
	COM_INTERFACE_ENTRY(IDispatch)
	COM_INTERFACE_ENTRY(IErrorInfo)
	COM_INTERFACE_ENTRY(ICDSSFunctionObject)
	COM_INTERFACE_ENTRY(ICDSSFunctionObject2)
	COM_INTERFACE_ENTRY(ICDSSNNGenericFunction)
END_COM_MAP()

// [!output FUNCNNGEN_INTERFACE]
public:
// IErrorInfo
	STDMETHOD(GetDescription)(BSTR *pDesc);
	STDMETHOD(GetGUID)(struct _GUID *);
	STDMETHOD(GetSource)(BSTR *);
	STDMETHOD(GetHelpFile)(BSTR *);
	STDMETHOD(GetHelpContext)(unsigned long *);
// ICDSSFunctionObject2
	STDMETHOD(get_FunctionType)(EnumDSSFunctionType *pType);
	STDMETHOD(SetProperty)(Int_32 Index, VARIANT *pValue);
	STDMETHOD(get_Description)(BSTR *pDescription);
	STDMETHOD(get_ParamCount)(Int_32 *pInCount, Int_32 *pOutCount, Int_32 *pRepeatCount);
	STDMETHOD(get_ParamInfo)(Int_32 ParamIndex, Int_32 InParameter, BSTR *pName, enum EnumDSSParameterType *pType);
	STDMETHOD(get_SqlType)(enum EnumDSSFunctionSQLType *pSqlType);
	STDMETHOD(get_PropertyCount)(Int_32 *pCount);
	STDMETHOD(get_PropertyInfo)(Int_32 PropertyIndex, BSTR *pName, BSTR *pDescription, VARIANT *pValue);
// ICDSSNNGenericFunction
	STDMETHOD(Calculate)();
	STDMETHOD(GetOutput)(Int_32 nSize, Int_32 *nDataSize, VARIANT *pData, DSSData_Flags *pFlag);
	STDMETHOD(GetOutputType)(Int_32 nSize, EnumDSSDataType *pInputType, EnumDSSDataType *pOutputDataType, EnumDSSParameterType *pOutputParamType);
	STDMETHOD(SetInputParam)(Int_32 nParamIndex, Int_32 nSize, EnumDSSDataType dataType, VARIANT *pData, DSSData_Flags *pFlag);
	STDMETHOD(GetInputParamType)(Int_32 nParamIndex, EnumDSSParameterType *pType);
	STDMETHOD(Clear)();
	STDMETHOD(IsNullProcessable)(VARIANT_BOOL * pCanProcessNULL)
	{
		if (pCanProcessNULL == NULL)
			return E_POINTER;
			
		*pCanProcessNULL = VARIANT_TRUE;

		return S_OK;
	}
[!if RFUNCS_DEFINED != ""]
	STDMETHOD(Init)(Int_32 lFunctionIndex, [!output FUNCPACKAGE_CLASSNAME] *pPKG, bool bRFunc);
[!else]
	STDMETHOD(Init)(Int_32 lFunctionIndex);
[!endif]
// support functions
	STDMETHOD(ConvertFromVariant)(VARIANT *pVar, enum EnumDSSDataType iType, BYTE *pData);
	STDMETHOD(getParamFromVariant)(VARIANT *pParam, Int_32 index, enum EnumDSSDataType type, BYTE *outResult);
private:
	Int_32 m_lFunctionIndex;				// current function index
	wchar_t m_sErrMsg[ERRMSG_BUFSIZE];		// function plug-in error message buffer
[!if RFUNCS_DEFINED != ""]
	bool m_bRFunc;							// indicates R function
	[!output FUNCPACKAGE_CLASSNAME] *m_pPKG;		// pointer to FP package object
	CRSupport *m_pRSupp;					// pointer to package RSupport object
[!endif]
[!if FUNCNNGEN_VECTOR_INPUT != ""]
	Int_32 m_lInputSize;					// number of input rows
[!endif]
	Int_32 m_lRepeatCnt;					// number of input columns for last repeated input
[!loop = FUNCNNGEN_COUNT]
	// [!output OUTPUT_DIRECTIVE] FUNCNNGEN_FUNCNAME_[!output LOOP_COUNTER]] parameters
[!output OUTPUT_DIRECTIVE] FUNCNNGEN_INPARAMDECLS_[!output LOOP_COUNTER]]
[!output IF_DIRECTIVE] FUNCNNGEN_PROPVARS_[!output LOOP_COUNTER] != ""]
[!output OUTPUT_DIRECTIVE] FUNCNNGEN_PROPVARS_[!output LOOP_COUNTER]]
[!output ENDIF_DIRECTIVE][!endloop]
	// TODO: add any member variables required by your function plug-in(s)

[!loop = FUNCNNGEN_COUNT]	STDMETHOD([!output OUTPUT_DIRECTIVE] FUNCNNGEN_FUNCNAME_[!output LOOP_COUNTER]])(Int_32 nSize, Int_32 *nDataSize, VARIANT *pData, DSSData_Flags *pFlag);
[!endloop]};
[!endif]
[!if FUNCAGG_COUNT]

//=======================================================================
// [!output FUNCAGG_CLASSNAME]
//=======================================================================
class ATL_NO_VTABLE [!output FUNCAGG_CLASSNAME] : 
	public CComObjectRootEx<CComMultiThreadModel>,
	public CComCoClass<[!output FUNCAGG_CLASSNAME], &[!output FUNCAGG_CLSIDNAME]>,
	public IDispatchImpl<[!output FUNCAGG_INTERFACE], &[!output FUNCAGG_DEFIIDNAME], &LIBID_[!output safe_root]Lib>,
	public IErrorInfo,
	public ICDSSFunctionObject2,
	public ICDSSAggregationFunction
{
public:
	[!output FUNCAGG_CLASSNAME]();
	~[!output FUNCAGG_CLASSNAME]();

DECLARE_REGISTRY_RESOURCEID(IDR_[!output SAFE_ROOT])

DECLARE_PROTECT_FINAL_CONSTRUCT()

BEGIN_COM_MAP([!output FUNCAGG_CLASSNAME])
	COM_INTERFACE_ENTRY([!output FUNCAGG_INTERFACE])
	COM_INTERFACE_ENTRY(IDispatch)
	COM_INTERFACE_ENTRY(IErrorInfo)
	COM_INTERFACE_ENTRY(ICDSSFunctionObject)
	COM_INTERFACE_ENTRY(ICDSSFunctionObject2)
	COM_INTERFACE_ENTRY(ICDSSAggregationFunction)
END_COM_MAP()

// [!output FUNCAGG_INTERFACE]
public:
// IErrorInfo
	STDMETHOD(GetDescription)(BSTR *pDesc);
	STDMETHOD(GetGUID)(struct _GUID *);
	STDMETHOD(GetSource)(BSTR *);
	STDMETHOD(GetHelpFile)(BSTR *);
	STDMETHOD(GetHelpContext)(unsigned long *);
// ICDSSFunctionObject2
	STDMETHOD(get_FunctionType)(EnumDSSFunctionType *pType);
	STDMETHOD(SetProperty)(Int_32 Index, VARIANT *pValue);
	STDMETHOD(get_Description)(BSTR *pDescription);
	STDMETHOD(get_ParamCount)(Int_32 *pInCount, Int_32 *pOutCount, Int_32 *pRepeatCount);
	STDMETHOD(get_ParamInfo)(Int_32 ParamIndex, Int_32 InParameter, BSTR *pName, enum EnumDSSParameterType *pType);
	STDMETHOD(get_SqlType)(enum EnumDSSFunctionSQLType *pSqlType);
	STDMETHOD(get_PropertyCount)(Int_32 *pCount);
	STDMETHOD(get_PropertyInfo)(Int_32 PropertyIndex, BSTR *pName, BSTR *pDescription, VARIANT *pValue);
// ICDSSAggregationFunction
	STDMETHOD(Calculate)(Int_32 nSize, double *pVec, double *pResult, DSSData_Flags *pFlag);
	STDMETHOD(CalculateRepeat)(Int_32 nSize, Int_32 nRepeat, Int_32 *pStartPoint, double *pVec, DOUBLE *opResult, DSSData_Flags *pFlag);
[!if RFUNCS_DEFINED != ""]
	STDMETHOD(Init)(Int_32 lFunctionIndex, [!output FUNCPACKAGE_CLASSNAME] *pPKG, bool bRFunc);
[!else]
	STDMETHOD(Init)(Int_32 lFunctionIndex);
[!endif]
private:
	Int_32 m_lFunctionIndex;				// current function index
	wchar_t m_sErrMsg[ERRMSG_BUFSIZE];		// function plug-in error message buffer
[!if RFUNCS_DEFINED != ""]
	bool m_bRFunc;							// indicates R function
	[!output FUNCPACKAGE_CLASSNAME] *m_pPKG;		// pointer to FP package object
	CRSupport *m_pRSupp;					// pointer to package RSupport object
[!endif]
[!loop = FUNCAGG_COUNT]
[!output IF_DIRECTIVE] FUNCAGG_PROPVARS_[!output LOOP_COUNTER] != ""]
[!output OUTPUT_DIRECTIVE] FUNCAGG_PROPVARS_[!output LOOP_COUNTER]]
[!output ENDIF_DIRECTIVE][!endloop]
	// TODO: add any member variables required by your function plug-in(s)

[!loop = FUNCAGG_COUNT]	STDMETHOD([!output OUTPUT_DIRECTIVE] FUNCAGG_FUNCNAME_[!output LOOP_COUNTER]])(Int_32 nSize, double *pVec, double *pResult, DSSData_Flags *pFlag);
[!endloop]};
[!endif]

#endif //__FPCLASSES_H_
